package StudyCode.summary.textfile;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReadFileByFileNameAndSaveToString {
	public static void main(String[] argv) {
		String fileName = "E:/Copy/test1.txt";
		System.out.println(readFile(fileName));
	}

	public static String readFile(String filename) {
		StringBuilder buf = new StringBuilder();
		try {
			BufferedReader input = new BufferedReader(new FileReader(
					filename));
			String line;

			while ((line = input.readLine()) != null) {
				buf.append(line);
				buf.append(System.getProperty("line.separator"));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return buf.toString();
	}
}
